type apiFunction = () => Promise<void>;

export default function useLazyLoad(apiFunction: apiFunction) {
  const target = ref<HTMLDivElement>();
  const { stop } = useIntersectionObserver(target, ([{ isIntersecting }]) => {
    if (isIntersecting) {
      stop();
      apiFunction();
    }
  });
  return target;
}
